package com.linxz.wandnroid.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.linxz.wandnroid.R;


/**
 * @author Linxz
 * 创建日期：2020年02月24日 15:32
 * version：v4.5.4
 * 描述：
 */
public class LayoutDivider extends FrameLayout {

    private String tittleName;
    private TextView tvTittleName;
    public LayoutDivider(@NonNull Context context) {
        super(context);
    }

    public LayoutDivider(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context,attrs,0);
    }

    public LayoutDivider(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.LayoutDivider, defStyleAttr, 0);
        tittleName=array.getString(R.styleable.LayoutDivider_layoutTittleName);
        array.recycle();
        init();
    }

    private void init(){
        LayoutInflater.from(getContext()).inflate(R.layout.wandroid_view_layout_divider,this);
        tvTittleName = findViewById(R.id.tvTittleName);
        if (!TextUtils.isEmpty(tittleName)){
            tvTittleName.setText(tittleName);
        }
    }

    public void setTittleName(String tittleName){
        tvTittleName.setText(tittleName);
    }
}
